﻿using BW.MesProject.Public.ErrorCode;
using BW.MesProject.WareHouse.Application;
using BW.MesProject.WareHouse.Domain;
using BW.MesProject.WareHouse.Infrastructure;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BW.MesProject.WareHouse.Host.Controllers
{
    /// <summary>
    /// 基础信息
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BasicInfoController : ControllerBase
    {
        // GET: api/<ShelvesController>
        private readonly IEMPServices EMPServices;
        private readonly IWHTypeServices WHTypeServices;
        private readonly ISupplierServices SupplierServices;
        private readonly ITagParseRulesServices TagParseRulesServices;
        private readonly IBaseServices baseServices;

        public BasicInfoController(IEMPServices EMPServices, IWHTypeServices WHTypeServices, ISupplierServices supplierServices, ITagParseRulesServices tagParseRulesServices, IBaseServices baseServices)
        {
            this.EMPServices = EMPServices;
            this.WHTypeServices = WHTypeServices;
            this.SupplierServices = supplierServices;
            TagParseRulesServices = tagParseRulesServices;
            this.baseServices = baseServices;
        }

        /// <summary>
        /// 获取人员信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<EMPModel>> GetEMP(string? EmpName, int pagesize, int pageNum, string DepId)
        {
            return EMPServices.GetEMP(EmpName,pagesize, pageNum,DepId);
        }

        /// <summary>
        /// 获取仓库类型信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<WareHouseTypeModel>> GetWareHouseType(string? WareTypeName)
        {
            return WHTypeServices.GetWareHouseType(WareTypeName);
        }

        /// <summary>
        /// 获取供应商信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<SupplierModel>> GetSupplier(string? SupplierName)
        {
            return SupplierServices.GetSupplier(SupplierName);
        }

        /// <summary>
        /// 获取标签解析规则
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<TagParseRulesModel>> GetTagParseRules(string? TagParseRulesName)
        {
            return TagParseRulesServices.GetTagParseRules(TagParseRulesName);
        }

        /// <summary>
        /// 获取编码
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<TypeCodeModel> GetCode(string Type)
        {
            return baseServices.GetCode(Type);
        }

        /// <summary>
        /// 修改编码
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdateCode(TypeCodeModel model)
        {
            return baseServices.UpdateCode(model);
        }
    }
}
